/**
 * project : sirius
 * user created : pippo
 * date created : 2007-7-16-下午03:06:03
 */
package com.bst.bsj.spring.util;

import javax.servlet.ServletContextEvent;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;


/**
 * Initialize spring WebApplicationContext and the BeanLocator.
 * 
 * @author pippo
 */
public class SpringInitListener extends ContextLoaderListener {

	private static Logger logger = Logger.getLogger(SpringInitListener.class);

	@Override
	public void contextInitialized(ServletContextEvent event) {
		logger.info("Begin init spring WebApplicationContext");
		super.contextInitialized(event);
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
		BeanLocator.setApplicationContext(context);
		logger.info("Spring WebApplicationContext init successful");
	}
}
